﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BattleShips.GameServers.CommandRunners {
    class Surrender : ICommandRunner {
        public string RunCommand(Common.Command command, TestServer.GameClient client, TestServer.GameServer server) {
            Dictionary<uint, GameRoom> rooms = new Dictionary<uint, GameRoom>();
            rooms = server.GetRooms();
            if (!client.PlayerStatus.Equals("Idle")) {
                foreach (var item in rooms[client.InRoomId].GetRoomClients().Values) {
                    if (client != item) {
                        rooms[client.InRoomId].GameIsEnd = true;
                        server.GameEnd(item, client, "surrender");
                    }
                }
            }
            return client.Username;
        }
    }
}
